package com.zhouu.example.member.manage.service.impl;

import com.zhouu.example.member.manage.service.ManageSystemUserService;
import com.zhouu.example.member.manage.vo.request.SystemUserLoginRequest;
import com.zhouu.example.member.manage.vo.response.SystemUserLoginResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

/**
 * @author zhouu
 * @date 2021-02-24 22:19
 */
@Slf4j
@Service
public class ManageSystemUserServiceImpl implements ManageSystemUserService {

    @Override
    public void test() {
        System.out.println("aaaa");
    }

    /**
     * 系统用户登录
     *
     * @param request 登录参数
     * @return SystemUserLoginResponse
     */
    @Override
    public SystemUserLoginResponse login(SystemUserLoginRequest request) {
        UsernamePasswordToken token = new UsernamePasswordToken(request.getUsername(), request.getPassword(), request.getRememberMe());
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
        return null;
    }
}
